﻿@model ShipmentModel

<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-form" wid100 lay-filter="">
            <input asp-for="Id" type="hidden" />
            <input asp-for="OrderId" type="hidden" />
            @if (Model.ShippingAddress != null)
            {
                var address = Model.ShippingAddress;
                <div class="layui-form-item">
                    <label class="layui-form-label">配送信息</label>
                    <div class="layui-form-mid layui-word-aux">
                        @address.Name  @address.PhoneNumber  <br />
                        @address.ProvinceName @address.CityName  @address.AreaName  @address.Address1
                    </div>
                </div>
            }
            <div class="layui-form-item">
                <u-label asp-for="ExpressName" />
                <div class="layui-input-inline">
                    <u-select asp-for="ExpressName" asp-items="@Model.AvailableExpressNames" />
                </div>
            </div>
            <div class="layui-form-item">
                <u-label asp-for="TrackingNumber" />
                <div class="layui-input-inline">
                    <u-editor asp-for="TrackingNumber" />
                </div>
            </div>
            <div class="layui-form-item">
                <u-label asp-for="ShippedDate" />
                <div class="layui-form-mid layui-word-aux">
                    @(Model.ShippedDate ?? "——")
                </div>
            </div>
            <div class="layui-form-item">
                <u-label asp-for="DeliveryDate" />
                <div class="layui-form-mid layui-word-aux">
                    @(Model.DeliveryDate ?? "——")
                </div>
                <div class="layui-form-mid layui-word-aux">
                    @if (Model.CanDeliver)
                    {
                        <button type="submit" name="setasdelivered" id="setasdelivered" class="layui-btn layui-btn-warm">
                            @T("Admin.Orders.Shipments.DeliveryDate.Button")
                        </button>
                    }
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button id="layuiadmin-app-form-submit" style="display:none" class="layui-btn" lay-submit lay-filter="set_system_submit_btn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set'], function () {
        var $ = layui.$
            , form = layui.form
            ,active = { }
        form.on('submit(set_system_submit_btn)', function (obj) {
          var field = obj.field; //获取提交的字段
            //layer.msg(JSON.stringify(obj.field));
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.post('@Url.Action("ShipmentDetails")', field, function (rep) {
                if (rep.success==1)
              layer.msg('保存成功');
            });
            return false;
         });
        $('.layui-btn.layuiadmin-btn-tags').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

</script>
